set auto_path [concat [pwd]/../../pkg/tkMD $auto_path ]

package require tkMD 1.1

if { [llength $argv] == 1 } {
  set protocolfile [lindex $argv 0]
  if ![file exists $protocolfile] { puts "Do not have $protocolfile under current folder!";exit}
  set protocol [lindex [split [file rootname $protocolfile] /] end ]
} else {
   puts "Usage example:  $argv0 protol1"
  exit
}

namespace import SimTask::*
set SimTask::PdbPath [pwd]/pdb
set SimTask::TemplatePath [pwd]/template
set SimTask::JobPath [pwd]/job
set SimTask::RunPath [pwd]/$protocol
set SimTask::Njobs 48
printEnv
set SimTask::Charmmbin /usr/local/bin/charmm

set peptides { 2mlt 2mag 1f0d 1f0e 1f0f }
set type { neutral anionic}
array set anfr_table { anionic 0.3 low_anionic 0.1 high_anionic 1.0 neutral 0.0}
set temp 298
set thick 26
set ionc 0.1

set anfr @anfr_table(@type)
set preptime 5
set eqltime 10
set orientation o0
set force 5.0

#override current parameter with the ones given in the protocol file 
# This helps  run.tcl and ana.tcl consistent with each other 
source $protocolfile

#make the com bins
set com {}
for { set i  $wlo } { $i <= $whi } { set i [expr $i +($whi-$wlo)/($nbins-1)] } {
    lappend com $i
}


VarSpace options { type com force temp thick ionc anfr anfr_table orientation preptime eqltime }
foreach peptide $peptides {
    prepfiles $peptide {o0.crd o1.crd o2.crd o3.crd o4.crd pept.psf}
    run $nreplica $peptide run.inp options --autopath array(key)_value/ --combine run orientation
}
rmfiles $SimTask::RunPath  *.out

